package Service.StatisticalReport.StatisticalReportImpl;

import Dao.StatisticalReportDao.UpdateDao;
import Model.StatisticalReport.ReportClass;
import Model.StatisticalReport.ReportUpdateQuery;
import Service.StatisticalReport.ReportUpdateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ReportUpdateServiceImpl implements ReportUpdateService {

    @Resource
    UpdateDao dao;

    @Override
    public int updateDepartmentSummary(ReportUpdateQuery query) {
        if(query.getYear() <= 0){
            return 0;
        }
        return dao.updateDepartmentSummary(query);
    }

    @Override
    public int updateHomeSummary(ReportUpdateQuery query) {
        if(query.getYear() <= 0){
            return 0;
        }

        return dao.updateHomeSummary(query);
    }

    @Override
    public int updateEvaluateSummary(ReportUpdateQuery query) {
        if(query.getYear() <= 0){
            return 0;
        }
        return dao.updateEvaluateSummary(query);
    }

    @Override
    public int updateSettlementSummary(ReportUpdateQuery query) {
        if(query.getYear() <= 0){
            return 0;
        }
        return dao.updateSettlementSummary(query);
    }

    @Override
    public int updateMonthly(ReportUpdateQuery query) {
        if(query.getYear() <= 0){
            return 0;
        }
        return dao.updateMonthlySummary(query);
    }

    @Override
    public int update(ReportClass report, ReportUpdateQuery query) {
        switch (report){
            case EVALUATE:
                return updateEvaluateSummary(query);
            case HOME:
                return updateHomeSummary(query);
            case DEPARTMENT:
                return updateDepartmentSummary(query);
        }
        return 0;
    }
}
